<!doctype html>
<html class="x-admin-sm" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/extras/spring-security"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>登录-自习室预定系统</title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <meta http-equiv="Cache-Control" content="no-siteapp"/>
    <link rel="stylesheet" th:href="@{/css/font.css}">
    <link rel="stylesheet" th:href="@{/css/login.css}">
    <link rel="stylesheet" th:href="@{/css/xadmin.css}">
    <script type="text/javascript" th:src="@{/js/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/js/xadmin.js}"></script>
    <script th:src="@{/lib/layui/layui.js}" charset="utf-8"></script>
    <script th:src="@{/lib/dist/sliderVerify/sliderVerify.js}" charset="utf-8"></script>
    <script th:src="@{/lib/sliderVerify/sliderVerify.js}" charset="utf-8"></script>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body class="login-bg">
<div class="login layui-anim layui-anim-up">
    <div class="message">自习室预定系统 - 登录</div>
    <div id="darkbannerwrap"></div>

    <form class="layui-form" th:action="@{/auth/executeLogin}" method="post">
        <input name="username" placeholder="用户名或学号" type="text" lay-verify="required" class="layui-input">
        <hr class="hr15">
        <input name="password" lay-verify="required" placeholder="密码" type="password" class="layui-input">
        <hr class="hr15">

        <div class="layui-form-item">
            <label class="layui-form-label">登录类型</label>
            <div class="layui-input-block">
                <input type="radio" name="type" lay-verify="required" value="1" title="管理员">
                <input type="radio" name="type" lay-verify="required" value="2" title="学生" checked>
            </div>
        </div>

        <div class="layui-btn layui-btn-danger"
             style="width: 100%;font-size: 20px;text-align: center" th:if="${errorMsg} ne null" th:text="${errorMsg}">
        </div>
        <hr class="hr15" th:if="${errorMsg} ne null">
        <div id="slider"></div>
        <hr class="hr15">
        <a onclick="xadmin.open('注册账号','/toRegister')"
           style="width:49%;height: 48px;text-align: center;align-content: center;line-height: 48px;font-size: 14px"
           class="layui-btn layui-btn-lg layui-btn-normal">注册</a>
        <input value="登录" lay-submit lay-filter="login" type="submit" style="width: 49%">
        <hr class="hr15">
    </form>
</div>
<script>
    layui.config({
        base: '/lib/dist/sliderVerify/'
    }).use(['sliderVerify', 'jquery', 'form'], function () {
        var sliderVerify = layui.sliderVerify,
            $ = layui.jquery,
            form = layui.form;
        var slider = sliderVerify.render({
            elem: '#slider',
            onOk: function () {//当验证通过回调
                layer.msg("滑块验证通过");
            }
        })
    })
    layui.use(['form', 'layer'],
        function () {
            $ = layui.jquery;
            var form = layui.form,
                layer = layui.layer;
            //自定义验证规则
            form.verify({});

            //监听提交
            form.on('submit(formDemo)', function (data) {
                if (slider.isOk()) {//用于表单验证是否已经滑动成功
                    layer.msg(JSON.stringify(data.field));
                } else {
                    layer.msg("请先通过滑块验证");
                }
                return false;
            });
        });
</script>
<!-- 底部结束 -->
</body>
</html>
